<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">


    <ui:composition template="/WEB-INF/faces/template.xhtml">


        <!-- new title -->
        <ui:define name="title">
            Sunshine Hotel - book
        </ui:define>

        <!-- new content -->
        <ui:define name="content">

            <h1>
                Book a room
            </h1>

            <br/>

            <p:panel> 
                <h:form prependId="false">

                    <table border="0">
                        <tr>
                            <td>
                                From:
                            </td>
                            <td> 
                                <h:inputText label="From date" id="datepicker"  value="#{bookingBackingBean.fromDate}" size="30" required="true">
                                </h:inputText>
                                <h:message for="datepicker" />
                            </td>
                        </tr>  
                        <tr>
                            <td>
                                Nights:   
                            </td>
                            <td>
                                <h:inputText label="Number of nights" id="nights" value="#{bookingBackingBean.noOfNights}" size="5" required="true">
                                </h:inputText>
                                <h:message for="nights" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Bathroom:
                            </td>
                            <td>
                                <h:selectBooleanCheckbox id="bathroom" value="#{bookingBackingBean.bathroom}" />
                                <h:message for="bathroom" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Kitchen:   
                            </td>
                            <td>
                                <h:selectBooleanCheckbox id="kitchen" value="#{bookingBackingBean.kitchen}" />
                                <h:message for="kitchen" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Room type:   
                            </td>
                            <td>
                                <h:selectOneMenu id="roomType" value="#{bookingBackingBean.roomType}">

                                    <c:forEach items="${addRoomTypeControllerBean.roomType}" var="roomType">
                                        <f:selectItem itemLabel="#{roomType.name}" itemValue="#{roomType.name}"/>
                                    </c:forEach>

                                    <c:if test="#{addRoomTypeControllerBean.roomType != null}">
                                        <c:set property="#{addRoomBackingBean.roomType}" target="#{addRoomBackingBean.roomType}" value="#{addRoomTypeControllerBean.roomType}"/>
                                    </c:if>
                                    
                                </h:selectOneMenu>
                                <h:message for="roomType" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <h:commandButton value="Book" action="user/viewFreeRooms.xhtml" />
                            </td>
                        </tr>
                    </table>

                </h:form>
            </p:panel>
        </ui:define>

    </ui:composition>
</html>

